import pygame
from pygame.locals import *
from sys import exit
import os



class Menu:
    def __init__(self):
        self.controle_img = 0
        
        self.selecionado = ["menu_sel1.png", "menu_sel1.png", "menu_sel1.png", "menu_sel1.png", "menu_sel1.png", "menu_sel1.png", "menu_sel1.png", "menu_sel1.png",
                            "menu_sel2.png", "menu_sel2.png", "menu_sel2.png", "menu_sel2.png", "menu_sel2.png", "menu_sel2.png", "menu_sel2.png", "menu_sel2.png",
                            "menu_sel3.png", "menu_sel3.png", "menu_sel3.png", "menu_sel3.png", "menu_sel3.png", "menu_sel3.png", "menu_sel3.png", "menu_sel3.png",
                            "menu_sel4.png", "menu_sel4.png", "menu_sel4.png", "menu_sel4.png", "menu_sel4.png", "menu_sel4.png", "menu_sel4.png", "menu_sel4.png"]

    def mudaImagem(self):
        return self.selecionado[self.controle_img]
 
    def incrementaControle(self):
        if self.controle_img < 24:
            self.controle_img += 1
        else:
            self.controle_img = 0

 
    

class ExecutaMenu:


    def __init(self):
        #informacoes da tela
        self.menu = Menu()    
        #informacoes do menu
        self.lady_menu = pygame.image.load("img"+ os.sep +"lady"+ os.sep +"menu_sel.png")
        self.lady_size = lady_menu.get_size()
        self.lady_pos = (width/2 - lady_size[0]/2,20)

        self.jet_menu = pygame.image.load("img"+ os.sep +"jet"+ os.sep +"menu_sel.png")
        self.jet_size = jet_menu.get_size()
        self.jet_pos = (width/2 - jet_size[0]/2,lady_size[1]+10)
        
        #botao_pressionado
        self.press = False


    def executa(self):
         #informacoes da tela
        self.menu = Menu()
        self.width, self.height = 900,600
        self.cor = (8,91,47)
        pygame.init()
        self.tela = pygame.display.set_mode((self.width,self.height), 0, 32)
        pygame.display.set_caption("Menu")
        pygame.display.toggle_fullscreen()
        #informacoes do menu
        self.lady_menu = pygame.image.load("img"+ os.sep +"lady"+ os.sep +"menu_sel.png")
        self.lady_size = self.lady_menu.get_size()
        self.lady_pos = (20,self.width/4 - self.lady_size[0]/2)

        self.jet_menu = pygame.image.load("img"+ os.sep +"jet"+ os.sep +"menu_sel.png")
        self.jet_size = self.jet_menu.get_size()
        self.jet_pos = (self.lady_size[0]+30,self.width/4 - self.jet_size[0]/2)
    
        #botao_pressionado
        self.press = False
       
        while True:
            
            
            for event in pygame.event.get():
                    if event.type == QUIT:
                        exit(0)
            self.tela.fill(self.cor)
            self.mouse_pos = pygame.mouse.get_pos()
            self.mouse_press = pygame.mouse.get_pressed()

            if self.jet_pos[0] <= self.mouse_pos[0] <= self.jet_pos[0] + self.jet_size[0] and self.jet_pos[1] <= self.mouse_pos[1] <= self.jet_pos[1] + self.jet_size[1]:
                self.imagem_jet = self.menu.mudaImagem()
                self.menu.incrementaControle()
                self.jet_menu = pygame.image.load("img"+ os.sep +"jet"+ os.sep + self.imagem_jet)

                if self.mouse_press[0]:
                    self.press = True

                if self.press and not self.mouse_press[0]:
                    import executa
                    executa.Executa(2)
            else:
                self.jet_menu = pygame.image.load("img"+ os.sep +"jet"+ os.sep +"menu_sel.png")


            if self.lady_pos[0] <= self.mouse_pos[0] <= self.lady_pos[0] + self.lady_size[0] and self.lady_pos[1] <= self.mouse_pos[1] <= self.lady_pos[1] + self.lady_size[1]:
                self.imagem_lady = self.menu.mudaImagem()
                self.menu.incrementaControle()
                self.lady_menu = pygame.image.load("img"+ os.sep +"lady"+ os.sep + self.imagem_lady)
                if self.mouse_press[0]:
                    self.press = True

                if self.press and not self.mouse_press[0]:
                    import executa
                    executa.Executa(1)
                    
            else:
                self.lady_menu = pygame.image.load("img"+ os.sep +"lady"+ os.sep +"menu_sel.png")


            if not self.mouse_press[0]:
                self.press = False


            self.tela.blit(self.lady_menu, self.lady_pos)
            self.tela.blit(self.jet_menu, self.jet_pos)

            pygame.display.update()

            
menu = ExecutaMenu()
menu.executa()

        



        
        
